<!doctype html>
<!--[if IE 7 ]>    <html lang="en" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]>    <html lang="en" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]>    <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<head>
    <?php use_helper('I18N') ?>
    <?php include('scripts.php'); ?>

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- CSS Styles -->
	<link rel="stylesheet" href="/css/style.css">
	<link rel="stylesheet" href="/css/colors.css">

	<!-- Google WebFonts -->
	<link href='http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css'>
    <style type="text/css">
        .redbutton {
            background:#ae432e url('/images/btns/btn_red.png') repeat-x left top;
        }
    </style>
    <script>
	$(function() {
        $("#lang").change(function() {
            $("#doAction").val("lang");
            $("#loginForm").submit();
        });

        $("#btnLogin").click(function(){

        });

        $("#captchaimage").bind('click', function() {
            $.post('/captcha/newSession');
            $("#captchaimage").load('/captcha/imageRequest');
            return false;
        });

        $("#loginForm").validate({
            rules: {
                <?php if (sfConfig::get('sf_environment') == Globals::SF_ENVIRONMENT_PROD) { ?>
                captcha: {
                    required: true,
                    remote: "/captcha/process"
                }
                <?php } ?>
            },
            messages: {
                captcha: "Correct captcha is required."
            },
            submitHandler: function(form) {
                if ("" == $("#doAction").val()) {
                    <?php if (sfConfig::get('sf_environment') == Globals::SF_ENVIRONMENT_PROD) { ?>
                    if ($.trim($("#username").val()) == "") {
                        alert("Shareholder ID cannot be blank.");
                        $("#username").focus();
                        return false;
                    }
                    if ($.trim($("#userpassword").val()) == "") {
                        alert("Password cannot be blank.");
                        $("#userpassword").focus();
                        return false;
                    }
                    <?php } ?>
                }

                form.submit();
            }
        });
        /*alert("<p>致广大的股东们，</p>"
            + "<p>本公司为了解决少许的技术问题，将会在十二点正关闭股东登陆服务达三小时。请任何要报单的股东们稍后再报单或登陆。谢谢。 </p>"
            + "<p>Tune Ventures电脑管理部</p>"
                + "<br>"
                + "<p>Dear All Valued Shareholders, </p>"
                + "<p>In order to solve a little technical issue, our company decided to shut down the shareholder login system for 3 HOURS time start from 12am. If there is any new registration, kindly do it after this down time. Thank you.</p>"
                + "<p>Tune Ventures IT Department</p>"
        + "</dl>");*/
	});
    function alert(data) {
        var msgs = "";
        if ($.isArray(data)) {
            jQuery.each(data, function(key, value) {
                msgs = value + "<br>";
            });
        } else {
            msgs = data + "<br>";
        }

        var alertPanel = "<div style='margin-bottom: 20px; padding: 0 .7em;' class='ui-state-highlight ui-corner-all'><p><span style='float: left; margin-right: .3em;' class='ui-icon ui-icon-info'></span>";
        alertPanel += msgs +"</p></div>";
        $("#waitingLB h3").html(alertPanel);
        $.blockUI({
            message: $("#waitingLB")
                , css: {
                    border: 'none',
                    padding: '5px',
                    '-webkit-border-radius': '10px',
                    '-moz-border-radius': '10px',
                    'border-radius': '10px',
                    opacity: .9
        }});
        $(".blockOverlay").css("z-index", 1010);
        $(".blockPage").css("z-index", 1011);
        $('.blockOverlay').attr('title','Click to unblock').click($.unblockUI);
    }
	</script>
</head>
<div id="waitingLB" style="display:none; cursor: default">
    <h3>We are processing your request.  Please be patient.</h3>
</div>
<body class="login">
	<section role="main">

		<div><img src="/images/logo.png" alt="tune" style="height: 80px"></div>

		<!-- Login box -->
		<article id="login-box">

			<div class="article-container">

				<form action="/home/doLogin" id="loginForm" method="post">
                    <input type="hidden" name="doAction" id="doAction" value="">
					<fieldset>
						<dl>
							<dt>
								<label><?php echo __('Shareholder ID') ?></label>
							</dt>
							<dd>
								<input type="text" name="username" id="username" class="large" value="<?php echo $username; ?>">
							</dd>
							<dt>
								<label><?php echo __('Password') ?></label>
							</dt>
							<dd>
								<input type="password" name="userpassword" id="userpassword" class="large" value="<?php echo $userpassword; ?>">
							</dd>
							<dt>
								<label><?php echo __('Language') ?></label>
							</dt>
							<dd>
								<select name="lang" id="lang">
                                    <option value="en"
                                      <?php
                                        if ($sf_user->getCulture() == "en")
                                        echo 'selected'
                                        ?>
                                        >English</option>
                                    <option value="cn"
                                      <?php
                                        if ($sf_user->getCulture() == "cn")
                                        echo 'selected'
                                        ?>
                                    >中文</option>
                                </select>
							</dd>
						</dl>
					</fieldset>
                    <?php if ($sf_flash->has('errorMsg')) { ?>
                        <div class="notification error">
                            <p><strong><?php echo $sf_flash->get('errorMsg') ?></strong></p>
                        </div>
                    <?php }
                    if ($appSetting->getSettingValue()=='0') {
                    ?>
					<button type="submit" class="right redbutton"><?php echo __('Login') ?></button>
                    <?php } ?>
				</form>

			</div>

		</article>
		<!-- /Login box -->
		<ul class="login-links">
			<li><a href="/member/register"><?php echo __('Register') ?></a></li>
			<li><a href="/member/forgetPassword"><?php echo __('Forget Password?') ?></a></li>
		</ul>

	</section>
</body>
</html>